package com.heima.article.controller.v1;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.heima.article.service.AuthorService;
import com.heima.model.article.pojos.ApAuthor;
import com.heima.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/article/api/v1/article")
public class AuthorController {
    @Autowired
    private AuthorService authorService;

    @GetMapping("{id}")
    public ResponseResult findByUserId(@PathVariable("id") Integer id){
        ApAuthor apAuthor = authorService.getOne(Wrappers.<ApAuthor>lambdaQuery().eq(ApAuthor::getId, id));
        return ResponseResult.okResult(apAuthor);
    }

    @PostMapping("save")
    public ResponseResult save(@RequestBody ApAuthor apAuthor){
        authorService.save(apAuthor);
        return ResponseResult.okResult();

    }
}
